import 'package:flutter/material.dart';
import 'package:p_location/common/constant/color_list.dart';

class ExpandOrCollapseView extends StatefulWidget {
  final bool isHiddenLIne;
  final Function onTap;
  final bool expandFlag;

  ExpandOrCollapseView(this.expandFlag, this.isHiddenLIne, this.onTap);

  @override
  _ExpandOrCollapseViewState createState() => _ExpandOrCollapseViewState();
}

class _ExpandOrCollapseViewState extends State<ExpandOrCollapseView> {
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        widget.onTap(!widget.expandFlag);
      },
      child: Container(
        color: Colors.white,
        child: Stack(
          children: [
            Offstage(
              offstage: widget.isHiddenLIne,
              child: FractionallySizedBox(
                widthFactor: 1,
                child: Container(
                  color: Color.fromRGBO(0, 0, 0, 0.1),
                  height: 0.5,
                  child: Text("12"),
                ),
              ),
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                IconButton(
                    onPressed: null,
                    icon: Icon(
                        widget.expandFlag
                            ? Icons.keyboard_arrow_up
                            : Icons.keyboard_arrow_down,
                        color: ColorList.BLACK_45)),
                Text(
                  widget.expandFlag ? "收起" : "更多",
                  style: TextStyle(color: ColorList.BLACK_45),
                ),
              ],
            )
          ],
        ),
      ),
    );
  }
}
